<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="/struts-tags" prefix="s" %>

<s:if test="isUpdate == false">
    <s:set name="title" value="%{'Add'}"/>
    <s:set name="action" value="%{'insert'}"/>
</s:if>
<s:else>
    <s:set name="title" value="%{'Edit'}"/>
    <s:set name="action" value="%{'update'}"/>
</s:else>

<br/>
<table>
    <tr>
        <td>
            <img src="<s:url value="/img/icons/user1.png"/>"> 
        </td>
        <td>
            <span class="title">
                <s:property value="#title"/> User
            </span>
        </td>
    </tr>
</table>
<br/><br/>

<s:form namespace="/user" action="%{action}">
    <s:actionerror/>
    <table>
        <s:if test="isUpdate == true">
            <tr>
                <td valign="top">
                    id:
                </td>
                <td>
                    <s:textfield name="user.userId" size="20" readonly="true" /> 
                </td>
            </tr> 
        </s:if>

        <tr>
            <td valign="top">
                user name:
            </td>
            <td>
                <s:textfield name="user.username" size="20" /> 
            </td>
            <td>
                <s:fielderror><s:param>user.username</s:param></s:fielderror>
            </td>
        </tr> 
        <tr>
            <td>
                password:
            </td>
            <td>
                <s:textfield name="user.password" size="20" />
            </td>
            <td>
                <s:fielderror><s:param>user.password</s:param></s:fielderror>
            </td>
        </tr> 
        <tr>
            <td>
                email:
            </td>
            <td>
                <s:textfield name="user.email" size="20" /> 
            </td>
            <td>
                <s:fielderror><s:param>user.email</s:param></s:fielderror>
            </td>
        </tr> 
        <tr>
            <td>
                role:
            </td>
            <td>
                <s:select name="user.role" list="{'admin','student','lecturer'}"/>
            </td>
            <td>
                <s:fielderror><s:param>user.role</s:param></s:fielderror>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <s:hidden name="isUpdate" value="isUpdate"/>
                <br/>
                <s:submit label="submit"/>
                &nbsp;&nbsp;&nbsp;
                <s:submit label="Cancel" value="Cancel" action="list_all" />
            </td>
        </tr>
    </table>
</s:form>
